//
//  SingleVip.m
//  FileStorage
//
//  Created by wanglei on 17/1/15.
//  Copyright © 2017年 wanglei. All rights reserved.
//

#import "SingleVip.h"

//定义成宏 方便下面使用 也可以减少出错
#define kName @"name"
#define kAssets @"assets"
#define kCar @"car"
#define kAge @"age"
@implementation SingleVip
#pragma mark---NSCoding必须实现的两个-----
//编码 这个方法就是将对象转化成data的时候会执行的
- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:_name forKey:kName];
    [aCoder encodeObject:_assets forKey:kAssets];
    [aCoder encodeObject:_car forKey:kCar];
    [aCoder encodeInt:_age forKey:kAge];
}
//反编码
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]) {
        _name = [aDecoder decodeObjectForKey:kName];
        _assets = [aDecoder decodeObjectForKey:kAssets];
        _age= [aDecoder decodeIntForKey:kAge];
        _car = [aDecoder decodeObjectForKey:kCar];
    }
    return self;
}
@end
